package com.maiji.cloud.controller.community;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.community.ComSearchInputDto;
import com.maiji.cloud.response.BaseOutPutDto;
import com.maiji.cloud.response.community.ComActivityDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/community")
@Api(tags = {"社区"})
public class ComActController extends BaseController{

    @PostMapping("/searchAct")
    @ApiOperation("搜索活动")
    public BaseOutPutDto<List<ComActivityDto>> searchAct(@RequestBody BaseInputDto<ComSearchInputDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/searchAct", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/hotActs")
    @ApiOperation("热门活动列表")
    public BaseOutPutDto<List<ComActivityDto>> hotActs(@RequestBody BaseInputDto inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/hotActs", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/addAct")
    @ApiOperation("添加活动")
    public BaseOutPutDto<String> addAct(@RequestBody BaseInputDto<ComActivityDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/addAct", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/addActs")
    @ApiOperation("添加活动列表")
    public BaseOutPutDto<String> addActs(@RequestBody BaseInputDto<ArrayList<ComActivityDto>> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/addActs", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/addHotAct")
    @ApiOperation("添加热门活动")
    public BaseOutPutDto<String> addHotAct(@RequestBody BaseInputDto<ComActivityDto>inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/addHotAct", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/addHotActs")
    @ApiOperation("添加热门活动列表")
    public BaseOutPutDto<String> addHotActs(@RequestBody BaseInputDto<ArrayList<ComActivityDto>>inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/addHotActs", inputDto, BaseOutPutDto.class);
    }

    /**
     * 修改活动
     * @param inputDto
     * @return
     */
    @PostMapping("/updateAct")
    @ApiOperation("修改活动")
    public BaseOutPutDto<String> updateAct(@RequestBody BaseInputDto<ComActivityDto>inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/updateAct", inputDto, BaseOutPutDto.class);
    }

    /**
     * 删除活动
     * @param inputDto
     * @return
     */
    @PostMapping("/deleteAct")
    @ApiOperation("删除活动")
    public BaseOutPutDto<String> deleteAct(@RequestBody BaseInputDto<ComActivityDto>inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/deleteAct", inputDto, BaseOutPutDto.class);
    }

}
